{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 语音数据合成脚本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fetch token begin\n",
      "{\"refresh_token\":\"25.0fa205013bf6af2fb8355c29f00c0df0.315360000.2060924932.282335-118650883\",\"expires_in\":2592000,\"session_key\":\"9mzdCr2LulnsFP8goHiNwRftx1B8cgU6Eci5xaHqxYI1U3ak57yKtS6CJK2LUS4upvACAFdUH0atyWbsD6ivLuXUipuOTu4=\",\"access_token\":\"24.19ae34d6d19935c68c2d6fe693c3a9c5.2592000.1748156932.282335-118650883\",\"scope\":\"public audio_voice_assistant_get audio_tts_post brain_all_scope brain_enhanced_asr brain_speech_realtime brain_asr_async wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\\u6743\\u9650 vis-classify_flower lpq_\\u5f00\\u653e cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base smartapp_mapp_dev_manage iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_\\u5f00\\u653eScope vis-ocr_\\u865a\\u62df\\u4eba\\u7269\\u52a9\\u7406 idl-video_\\u865a\\u62df\\u4eba\\u7269\\u52a9\\u7406 smartapp_component smartapp_search_plugin avatar_video_test b2b_tp_openapi b2b_tp_openapi_online smartapp_gov_aladin_to_xcx\",\"session_secret\":\"bfb8a9f2da465f66c5082d6960e85345\"}\n",
      "\n",
      "{'refresh_token': '25.0fa205013bf6af2fb8355c29f00c0df0.315360000.2060924932.282335-118650883', 'expires_in': 2592000, 'session_key': '9mzdCr2LulnsFP8goHiNwRftx1B8cgU6Eci5xaHqxYI1U3ak57yKtS6CJK2LUS4upvACAFdUH0atyWbsD6ivLuXUipuOTu4=', 'access_token': '24.19ae34d6d19935c68c2d6fe693c3a9c5.2592000.1748156932.282335-118650883', 'scope': 'public audio_voice_assistant_get audio_tts_post brain_all_scope brain_enhanced_asr brain_speech_realtime brain_asr_async wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test权限 vis-classify_flower lpq_开放 cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base smartapp_mapp_dev_manage iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_开放Scope vis-ocr_虚拟人物助理 idl-video_虚拟人物助理 smartapp_component smartapp_search_plugin avatar_video_test b2b_tp_openapi b2b_tp_openapi_online smartapp_gov_aladin_to_xcx', 'session_secret': 'bfb8a9f2da465f66c5082d6960e85345'}\n",
      "SUCCESS WITH TOKEN: 24.19ae34d6d19935c68c2d6fe693c3a9c5.2592000.1748156932.282335-118650883 ; EXPIRES IN SECONDS: 2592000\n",
      "result saved as :result.wav\n",
      "********** Start playing! **********\n",
      "********** Stop playing! **********\n"
     ]
    },
    {
     "ename": "TypeError",
     "evalue": "savewave() takes 2 positional arguments but 3 were given",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[9], line 11\u001b[0m\n\u001b[0;32m      9\u001b[0m r \u001b[38;5;241m=\u001b[39m recorder()\n\u001b[0;32m     10\u001b[0m r\u001b[38;5;241m.\u001b[39mplaywav(file)\n\u001b[1;32m---> 11\u001b[0m \u001b[43mr\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msavewave\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfile\u001b[49m\u001b[43m,\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mmerged.wav\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n",
      "\u001b[1;31mTypeError\u001b[0m: savewave() takes 2 positional arguments but 3 were given"
     ]
    }
   ],
   "source": [
    "#导入依赖包\n",
    "import tts as tts#百度语音合成包\n",
    "from RecordPlay import recorder#录音包\n",
    "#需要语音合成的内容\n",
    "text = \"今天天气真好呀！\"\n",
    "#语音合成    \n",
    "file = tts.Text2Voice(text)\n",
    "#播放语音文件\n",
    "r = recorder()\n",
    "r.playwav(file)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "fordetect",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.20"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
